<?
	class StateBO extends BusinessObject {
	function setAttributes(){
		$this->fields   = array(
			"id" 	     =>	"sttID",
			"name"	     =>	"sttName",
			"country_id" =>	"sttCountryId"
			);

			BusinessObject::setAttributes();
	}
	function StateBO () {
		BusinessObject::BusinessObject("states");
		$this->setAttributes();
	}

  function getStateNameByID($id)
  {
    $this->id = $id;
    $this->Load(0,1);
    if($this->Next())
    {
      return $this->name;
    }else
    {
      return "";
    }
  }
  function get_states_as_html($selected_stateID,$country="")
  {
    $ret = "";
    if($country!="") $this->country_id = $country; 
    $this->Load(0,0,array($this->fields["name"] => "0"));
    while ($this->Next()) 
    {
      $ret.= "<option value='{$this->id}' ".(($selected_stateID==$this->id)?"selected":"").">".htmlspecialchars($this->name)."</option>";
    }
    return $ret;
  }
}
?>
